Skip to content

feat(providers): add SNMP provider for ingesting traps as alerts#6281

Closed
junaiddshaukat wants to merge 1 commit into
keephq:mainfrom
junaiddshaukat:feat/snmp-provider
Closed

feat(providers): add SNMP provider for ingesting traps as alerts#6281
junaiddshaukat wants to merge 1 commit into
keephq:mainfrom
junaiddshaukat:feat/snmp-provider

Conversation

@junaiddshaukat
Copy link
Copy Markdown

@junaiddshaukat junaiddshaukat commented Apr 22, 2026

What this PR does

Adds a passive SNMP provider. The user's existing snmptrapd daemon receives the trap; a tiny exec hook forwards it as JSON to Keep's webhook endpoint. The provider parses the payload into an AlertDto. Same webhook-receiver shape as the Prometheus / Grafana providers.

Why webhook-based and not a native UDP listener inside Keep? Port 162 is privileged, and a per-tenant/per-replica UDP listener inside the API server doesn't fit Keep's deployment model (horizontally scaled, no shared port claim). Delegating raw SNMP handling to snmptrapd keeps the provider small, stateless, deploy-shape-agnostic, and consistent with how every other monitoring-tool integration in the repo works.

Features

  • Built-in severity map for standard RFC 1907 / RFC 3418 trap OIDs (coldStart, warmStart, linkDown, linkUp, authenticationFailure, egpNeighborLoss)
  • User-configurable default_severity for unknown trap OIDs
  • Explicit severity field in the payload always wins
  • Varbinds exposed as labels["var:<oid>"] so they're queryable without clobbering top-level keys
  • Fingerprint = sha256(trap_oid|source_address) → same trap from same host dedupes correctly
  • simulate_alert with 4 representative trap fixtures for UI testing

Demo Video

Screen.Recording.2026-04-23.at.3.33.50.AM.mov

The video shows: connect the provider from the UI → POST a linkDown trap to the webhook URL → POST an authenticationFailure trap → both alerts land in the feed with correct severity (high, warning), source: snmp, and varbinds visible on the labels.

Testing that i have done

  • poetry run pytest tests/test_snmp_provider.py -v10 passed
  • poetry run pre-commit run --files <new files> → all green (black, isort, ruff, end-of-files, trailing whitespace)
  • Manual end-to-end: webhook round-trip verified; alerts appear in the feed within ~1s
image

Checklist

  • Follows CONTRIBUTING.md (PEP8, black, isort)
  • Tests added and passing
  • Documentation added
  • Provider icon added
  • No changes to unrelated files
  • simulate_alert works from the UI

Closes #2112

/claim #2112

Passive SNMP provider that receives traps via a small snmptrapd exec
hook forwarding parsed traps as JSON to Keep's webhook endpoint.

- _format_alert converts trap payload into AlertDto
- Built-in severity mapping for standard RFC 1907 / RFC 3418 trap OIDs
  (coldStart, warmStart, linkDown, linkUp, authenticationFailure,
  egpNeighborLoss) with a user-configurable default_severity fallback
- Varbinds exposed as labels["var:<oid>"]
- Fingerprint derived from (trap_oid, source_address) for deduplication
- Docs include snmptrapd.conf snippet and minimal bash bridge
- simulate_alert fixture for UI testing
- Unit tests for naming, severity resolution, fingerprinting, labels

Closes keephq#2112
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 22, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 22, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added Documentation Improvements or additions to documentation Feature A new feature Provider Providers related issues labels Apr 22, 2026
@junaiddshaukat
Copy link
Copy Markdown
Author

junaiddshaukat commented Apr 22, 2026

Hi @Matvey-Kuk @shahargl, Please have a look on this PR when you got chance, happy to iterate anything

@shahargl
Copy link
Copy Markdown
Member

shahargl commented May 3, 2026

N/A

@shahargl shahargl closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Bounty claim Documentation Improvements or additions to documentation Feature A new feature Provider Providers related issues size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🔌 Provider]: SNMP provider

3 participants